﻿@using MockSchoolManagement.Application.Dtos;
@model PagedResultDto<Course>

@{
    ViewBag.Title = "课程列表页面";
}
<h1>课程列表</h1>
<form asp-action="Index" method="get">

    <div class="form-actions no-color">
        <input type="hidden" name="CurrentPage" value="@Model.CurrentPage" />
        <input type="hidden" name="Sorting" value="@Model.Sorting" />
        <p>
            请输入名称: <input type="text" name="FilterText" value="@Model.FilterText" />
            <input type="submit" value="查询" class="btn btn-outline-dark" /> |
            <a asp-action="Index">返回所有列表</a>| <a asp-action="Create">
                添加
            </a>
        </p>
    </div>
</form>

<div class="  table-responsive-sm">
    @if (Model.Data.Any())
    {
        <table class="table table-bordered table-striped">
            <thead>
                <tr>

                    <th scope="col" class="sort-link">
                        <a asp-action="Index"
                           asp-route-Sorting="CourseID" asp-route-CurrentPage="@Model.CurrentPage" asp-route-FilterText="@Model.FilterText">
                            课程编号
                        </a>
                    </th>
                    <th>
                        <a asp-action="Index" asp-route-Sorting="Title " asp-route-CurrentPage="@Model.CurrentPage" asp-route-FilterText="@Model.FilterText">
                            课程名称
                        </a>
                    </th>
                    <th>
                        <a asp-action="Index" asp-route-Sorting="Credits " asp-route-CurrentPage="@Model.CurrentPage" asp-route-FilterText="@Model.FilterText">
                            课程学分
                        </a>
                    </th>
                    <th scope="col">操作</th>
                </tr>
            </thead>
            <tbody>

                @foreach (var item in Model.Data)
                {

                    <tr>
                        <td>@item.CourseID</td>
                        <td>@item.Title</td>
                        <td>@item.Credits</td>

                        <td>
                            <form method="post" asp-action="Delete" asp-route-id="@item.CourseID">
                                <a asp-controller="Course" class="btn btn-info" asp-action="Details" asp-route-id="@item.CourseID">查看</a>
                                <a asp-controller="Course" asp-action="edit" asp-route-id="@item.CourseID" class="btn btn-primary m-1">编辑</a>
                                <span id="confirmDeleteSpan_@item.CourseID" style="display: none">
                                    <span>你确定你要删除?</span>
                                    <button type="submit" class="btn btn-danger">是</button>
                                    <a href="#" class="btn btn-primary" onclick="confirmDelete('@item.CourseID', false)">
                                        否
                                    </a>
                                </span>
                                <span id="deleteSpan_@item.CourseID">
                                    <a href="#" class="btn btn-danger" onclick="confirmDelete('@item.CourseID', true)">删除</a>
                                </span>
                            </form>
                    </tr>
                }
            </tbody>
        </table>

    }

    @await Html.PartialAsync("_Pagination")
    @*@Html.Partial("_Pagination")
    <partial name="_Pagination" />*@
 

</div>

@section Scripts {
    <script src="~/js/CustomScript.js" asp-append-version="true"></script>
}